from django.db import models

# Create your models here.
class Grade(models.Model): # classes
    name = models.CharField(max_length=16,null=False,unique=True)
    
    class Meta:
        db_table = 'grade'
        ordering = ['id']

class Course(models.Model):
    name = models.CharField(max_length=32,unique=True,null=False)
    
    class Meta:
        db_table = 'course'
        ordering = ['id'] 
        

class Student(models.Model):
    name = models.CharField(max_length=16,null=False)
    age = models.IntegerField(null=True)
    gender = models.BooleanField(null=False)
    g = models.ForeignKey(Grade,on_delete=models.CASCADE)
    c = models.ManyToManyField(Course)
    
    class Meta:
        db_table = 'student'
        ordering = ['id']
        
class Teacher(models.Model):
    name = models.CharField(max_length=16,null=False)
    age = models.IntegerField(null=True)
    gender = models.BooleanField(null=False,help_text='性别')
    content = models.TextField(max_length=200,help_text="教师擅长简介")
    c = models.ManyToManyField(Course)
    g = models.ManyToManyField(Grade,help_text='所教年级')
    
    class Meta:
        db_table = 'teacher'
        ordering = ['-id']